<?php

class Silk_Zgb_Adminhtml_RmaController extends Mage_Adminhtml_Controller_Action
{
	protected function _initAction()
	{
			$this->loadLayout()->_setActiveMenu("sales")->_addBreadcrumb(Mage::helper("adminhtml")->__("取消/修改申请管理"),Mage::helper("adminhtml")->__("取消/修改申请管理"));
			return $this;
	}
	public function indexAction() 
	{
		    $this->_title($this->__("轻松老板"));
		    $this->_title($this->__("取消/修改申请管理"));
			$this->_initAction();
			$this->renderLayout();
	}

	public function massConfirmAction()
	{
		try {
			$ids = $this->getRequest()->getPost('ids', array());
			foreach ($ids as $id) {
                  $model = Mage::getModel("zgb/rma");
				  $model->load($id);
				  if(!$model->getStatus())
				  {
				  	$model->setStatus(1);
				  	$model->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate());
				  }
				  
				  $model->save();
			}
			Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("已处理！"));
		}
		catch (Exception $e) {
			Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
		}
		$this->_redirect('*/*/');
	}

	public function massRemoveAction()
	{
		try {
			$ids = $this->getRequest()->getPost('ids', array());
			foreach ($ids as $id) {
                  $model = Mage::getModel("zgb/warehouse");
				  $model->setId($id)->delete();
			}
			Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("已删除！"));
		}
		catch (Exception $e) {
			Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
		}
		$this->_redirect('*/*/');
	}

	protected function _isAllowed()
    {
    	return true;
        return Mage::getSingleton('admin/session')->isAllowed('zgb');
    }
}
